package com.example.teamtribe.database;

import android.os.Parcel;
import android.os.Parcelable;

import org.litepal.crud.DataSupport;

public class Request extends DataSupport implements Parcelable {

    private int id;
    private int realId;
    private int userId;
    private int id1;
    private int id2;
    private int result;
    private String requestReason;
    private String responseReason;
    private int isRead = 0;//只要不是0就是已读

    public Request() {
    }

    public synchronized boolean saveOrUpdate() {
        return saveOrUpdate("realId = ?", realId + "");
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Request) {
            Request request = (Request) obj;
            return this.realId == request.realId;
        }
        return false;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getRealId() {
        return realId;
    }

    public void setRealId(int realId) {
        this.realId = realId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getId1() {
        return id1;
    }

    public void setId1(int id1) {
        this.id1 = id1;
    }

    public int getId2() {
        return id2;
    }

    public void setId2(int id2) {
        this.id2 = id2;
    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public String getRequestReason() {
        return requestReason;
    }

    public void setRequestReason(String requestReason) {
        this.requestReason = requestReason;
    }

    public String getResponseReason() {
        return responseReason;
    }

    public void setResponseReason(String responseReason) {
        this.responseReason = responseReason;
    }

    public int isRead() {
        return isRead;
    }

    public void setRead(int read) {
        isRead = read;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeInt(this.realId);
        dest.writeInt(this.userId);
        dest.writeInt(this.id1);
        dest.writeInt(this.id2);
        dest.writeInt(this.result);
        dest.writeString(this.requestReason);
        dest.writeString(this.responseReason);
        dest.writeInt(this.isRead);
    }

    protected Request(Parcel in) {
        this.id = in.readInt();
        this.realId = in.readInt();
        this.userId = in.readInt();
        this.id1 = in.readInt();
        this.id2 = in.readInt();
        this.result = in.readInt();
        this.requestReason = in.readString();
        this.responseReason = in.readString();
        this.isRead = in.readInt();
    }

    public static final Creator<Request> CREATOR = new Creator<Request>() {
        @Override
        public Request createFromParcel(Parcel source) {
            return new Request(source);
        }

        @Override
        public Request[] newArray(int size) {
            return new Request[size];
        }
    };
}
